<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./template/StakeholderTemplate.xhtml">
    <ui:define name="contentInsert">
        <h:body>
            <h:form id="formMain">
                <h1>Stakeholder Add Branch</h1>

                <p:panel id="panel" header="Add New Branch">
                    <f:metadata>
                        <f:viewParam name ="autoConfirm" value ="#{stakeholderManagerBean.fnBIOTR.autoConfirm}" />
                    </f:metadata>
                    <p:ajaxStatus style="width:16px;height:16px;">
                        <f:facet name="start">
                            <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                        </f:facet>
                        <f:facet name="complete">
                            <h:outputText value="" />
                        </f:facet>
                    </p:ajaxStatus>
                    <p:messages />
                    <h:panelGrid columns="3" cellpadding="10">
                        <h:outputLabel for="name" style="font-weight: bold" value="Branch name: " />
                        <h:inputText required="true" label="Branch Name" requiredMessage="Brach name is required." id="name" value="#{stakeholderManagerBean.selectedBranch.name}">
                            <p:ajax event="blur" update="nameMsg"/>
                        </h:inputText>
                        <p:message id="nameMsg" for="name" />

                        <h:outputLabel for="address" style="font-weight: bold" value="Address: " />
                        <h:inputText required="true" label="Address" requiredMessage="Address is required." id="address" value="#{stakeholderManagerBean.branchAddress.houseNumber}">
                            <p:ajax event="blur" update="addressMsg"/>
                        </h:inputText>
                        <p:message id="addressMsg" for="address" />


                        <h:outputLabel for="phoneNumber" style="font-weight: bold" value="Phone Number: " />
                        <h:inputText required="true" label="Phone Number" requiredMessage="Phone Number is required." id="phoneNumber" value="#{stakeholderManagerBean.selectedBranch.contactNumber}">
                            <f:validator validatorId="customvalidator.PhoneNumberValidator" />
                            <p:ajax event="blur" update="phoneNumberMsg"/>
                        </h:inputText>
                        <p:message id="phoneNumberMsg" for="phoneNumber" />

                        <p:commandButton value="AutoConfirm" disabled="#{stakeholderManagerBean.fnBIOTR.autoConfirm}"  action="StakeholderAddBranch?faces-redirect=true" ajax="true">
                            <f:param name="autoConfirm" value="true" />
                        </p:commandButton>

                        <p:commandButton value="ManualConfirm" disabled="#{!stakeholderManagerBean.fnBIOTR.autoConfirm}" action="StakeholderAddBranch?faces-redirect=true" ajax="true">
                            <f:param name="autoConfirm" value="false" />
                        </p:commandButton>

                        <h:outputLabel for="blank" style="font-weight: bold" value=""/>
                        <h:outputLabel for="percentConfirm" style="font-weight: bold" value="PercentConfirm: " />
                        <h:inputText disabled="#{stakeholderManagerBean.fnBIOTR.autoConfirm}" required="#{stakeholderManagerBean.fnBIOTR.autoConfirm}" label="PercentConfirm" requiredMessage="Phone Number is required." id="percentConfirm" value="#{stakeholderManagerBean.fnBIOTR.percentManualConfirm}">
                            <p:ajax event="blur" update="percentConfirmMsg"/>
                        </h:inputText>
                        <p:message id="percentConfirmMsg" for="percentConfirm" />

                        <h:outputLabel for="changeFee" style="font-weight: bold" value="Change Fee: " />
                        <h:inputText label="change fee" id="changeFee" value="#{stakeholderManagerBean.fnBIOTR.changeFee}">
                            <p:ajax event="blur" update="changeFeeMsg"/>
                        </h:inputText>
                        <p:message id="changeFeeMsg" for="changeFee" />

                        <h:outputLabel for="showPercentCharge" style="font-weight: bold" value="Show Percent Charge: " />
                        <h:inputText label="Show Percent Charge" id="showPercentCharge" value="#{stakeholderManagerBean.fnBIOTR.showPercentCharge}">
                            <p:ajax event="blur" update="showPercentChargeMsg"/>
                        </h:inputText>
                        <p:message id="showPercentChargeMsg" for="showPercentCharge" />

                        <h:outputLabel for="noShowPercentCharge" style="font-weight: bold" value="No Show Percent Charge: " />
                        <h:inputText label="No Show Percent Charge" id="noShowPercentCharge" value="#{stakeholderManagerBean.fnBIOTR.noShowPercentCharge}">
                            <p:ajax event="blur" update="noShowPercentChargeMsg"/>
                        </h:inputText>
                        <p:message id="noShowPercentChargeMsg" for="noShowPercentCharge" />

                        <h:outputLabel for="eatingTime" style="font-weight: bold" value="Estimate Eating Time: " />
                        <h:selectOneMenu value="#{stakeholderManagerBean.fnBIOTR.eatingTime}" id="eatingTimeList">
                            <f:selectItem itemLabel="30 minutes" itemValue="0.5"></f:selectItem>
                            <f:selectItem itemLabel="45 minutes" itemValue="0.75"></f:selectItem>
                            <f:selectItem itemLabel="1 hour" itemValue="1"></f:selectItem>
                            <f:selectItem itemLabel="1 hour 15 minutes" itemValue="1.25"></f:selectItem>
                            <f:selectItem itemLabel="1 hour 30 minutes" itemValue="1.50"></f:selectItem>
                            <f:selectItem itemLabel="1 hour 45 minutes" itemValue="1.75"></f:selectItem>
                            <f:selectItem itemLabel="2 hours" itemValue="2"></f:selectItem>
                            <f:selectItem itemLabel="2 hour 15 minutes" itemValue="2.25"></f:selectItem>
                            <f:selectItem itemLabel="2 hour 30 minutes" itemValue="2.50"></f:selectItem>
                            <f:selectItem itemLabel="2 hour 45 minutes" itemValue="2.75"></f:selectItem>
                            <f:selectItem itemLabel="3 hours" itemValue="3"></f:selectItem>
                            <f:selectItem itemLabel="3 hour 15 minutes" itemValue="3.25"></f:selectItem>
                            <f:selectItem itemLabel="3 hour 30 minutes" itemValue="3.50"></f:selectItem>
                            <f:selectItem itemLabel="3 hour 45 minutes" itemValue="3.75"></f:selectItem>
                            <f:selectItem itemLabel="4 hours" itemValue="4"></f:selectItem>
                            <f:selectItem itemLabel="4 hours 15 minutes" itemValue="4.25"></f:selectItem>
                            <f:selectItem itemLabel="4 hours 30 minutes" itemValue="4.50"></f:selectItem>
                            <f:selectItem itemLabel="4 hour 45 minutes" itemValue="4.75"></f:selectItem>
                            <f:selectItem itemLabel="5 hours" itemValue="5"></f:selectItem>
                            <f:selectItem itemLabel="5 hour 15 minutes" itemValue="5.25"></f:selectItem>
                            <f:selectItem itemLabel="5 hour 30 minutes" itemValue="5.50"></f:selectItem>
                            <f:selectItem itemLabel="5 hour 45 minutes" itemValue="5.75"></f:selectItem>
                            <f:selectItem itemLabel="6 hours" itemValue="6"></f:selectItem>   
                        </h:selectOneMenu>
                        <p:message id="eatingTimeListMsg" for="eatingTimeList" />

                    </h:panelGrid>
                    <p:commandButton id="btn" value="Create New Branch" update="panel" actionListener="#{stakeholderManagerBean.createNewBranch}" ajax="true" />
                </p:panel>
            </h:form>
        </h:body>
    </ui:define>
</ui:composition>